#include <iostream>
#include <cstdio>
using namespace std;
long double f(long double x){
    return x*x*x-2.0*x-5.0;
}
int main()
{
    int cnt = 0;
    long double a = 2.0, b = 3.0, x, ep = 1e-18;
    while(b-a>ep){
        x = (a+b)/2;
        cout<<cnt++ <<endl;
        if(f(a)*f(x)<0){
            b = x;
        }
        else{
            a = x;
        }
    }
    //printf("%10Lf\n",x);
    cout<<"x = "<<x<<endl;
    cout<<"f(x) = "<<f(x)<<endl;

    a = 2.0, b = 3.0, ep = 1e-18;
    for(int i=0; i<100; i++){
        x = (a+b)/2;
        cout<<cnt++ <<endl;
        if(f(a)*f(x)<0){
            b = x;
        }
        else{
            a = x;
        }
    }
    cout<<"x = "<<x<<endl;
    cout<<"f(x) = "<<f(x)<<endl;
    return 0;
}
